package com.zzc.dao;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.zzc.bean.DiningReceipt;
import com.zzc.bean.Employee;
import com.zzc.bean.SystemSet;
import org.hibernate.Query;

import java.util.Date;
import java.util.List;

public class SystemSetDao extends BaseDao{
	public SystemSet getSystemSet(String userAccount){
		String hql = "FROM SystemSet systemSet WHERE systemSet.userNumber = ?";
		Query query = getSession().createQuery(hql).setString(0, userAccount);
		SystemSet systemSet = (SystemSet) query.uniqueResult();
		if (systemSet==null){
			systemSet=new SystemSet();
		}
		//System.out.println(employee.getDepartment().getClass().getName());
		String string=new Gson().toJson(systemSet);
		System.out.println("systemSet:"+string);
		return systemSet;
	}
	public boolean setAdvance(String userAccount, boolean isAdvance, String advanceDining_time, String signDate_time) {
		System.out.println(userAccount);
		SystemSet systemSet=new SystemSet();
		systemSet.setUserNumber(userAccount);
		systemSet.setAdvance(isAdvance);
		systemSet.setAdvanceDiningDate(advanceDining_time);
		systemSet.setSignDate(signDate_time);
		try {
			getSession().saveOrUpdate(systemSet);
		} catch (Exception e) {
			return false;
		}
//		}
		return true;
	}
}
